package edu.spec.chenli.Servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintStream;

@WebServlet(name = "TestListenerServlet",urlPatterns = "/tls")
public class TestListenerServlet extends HttpServlet {
    protected  void service(HttpServletRequest request,HttpServletResponse response)throws  ServletException,IOException{
        super.service(request,response);
        //给application添加number
        ServletContext application=super.getServletContext();
        application.setAttribute("number",0);
        //构造response
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charSet=UTF-8");
        PrintStream out = new PrintStream(response.getOutputStream());
        out.println("<html>");
        out.println("<body>");
        out.println("<h1>成功</h1>");
        out.println("</body>");
        out.println("</html>");
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
